/**
 * @description 博客api
 */
import { axios, _formateAxiosData } from './axiosInstance'

/***
  * 创建博客
  * @method createBlog
  * @param blogInfo
  * @returns {Promise}
  */
async function createBlog (blogInfo) {
  let result = await axios.post('/blog/createBlog', blogInfo)
  return _formateAxiosData(result)
}

/***
  * 获取第一页博客
  * @method getFirstBlog
  * @param id 用户id
  * @returns {Promise}
  */
async function getFirstBlog (id) {
  let result = await axios.get('/blog/getBlogList', {
    params: {
      id
    }
  })
  return _formateAxiosData(result)
}

/***
  * 加载更多博客
  * @method loadMoreBlog
  * @param id 用户id
  * @param index 当前分页
  * @returns {Promise}
  */
async function loadMoreBlog (id, index) {
  let result = await axios.get('/blog/getBlogList', {
    params: {
      id,
      index
    }
  })
  return _formateAxiosData(result)
}

export {
  createBlog,
  getFirstBlog,
  loadMoreBlog
}
